<?php

App::uses('AppController', 'Controller');

/**
 * Static content controller
 *
 * Override this controller by placing a copy in controllers directory of an application
 *
 * @package       app.Controller
 * @link http://book.cakephp.org/2.0/en/controllers/pages-controller.html
 */
class ContactController extends AppController {

	public $components = array(
		'Session'
	);

	public $helpers = array(
		'Session'
	);
	/**
	 * This controller does not use a model
	 *
	 * @var array
	 */
	public $uses = array('Contact');

	/**
	 * Displays a view
	 *
	 * @param mixed What page to display
	 * @return void
	 * @throws NotFoundException When the view file could not be found
	 *	or MissingViewException in debug mode.
	 */
	public function index() {

		$this->set('errors', '');
	}

	public function submit() {

		$this->Contact->set($this->request->data);

		if ($this->Contact->save($this->request->data)) {
		
			$this->Session->setFlash('Chúng tôi sẽ liên lạc lại với bạn ngay khi có thể, cảm ơn.');
			
		} else {
			$this->Session->setFlash('Có lỗi phát sinh !');
		}

		return $this->redirect('/contacts');
	}
}
